//
//  BaseTabBarController.m
//  Gift Show
//
//  Created by 史兴宇 on 16/3/23.
//  Copyright © 2016年 史兴宇. All rights reserved.
//

#import "BaseTabBarController.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
-(void)dealloc{
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"day" object:nil];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.tabBar.translucent = NO;
    BOOL result = [[NSUserDefaults standardUserDefaults] boolForKey:@"isNight"];
    
    if (result == YES) {
        /**夜间 */
        self.tabBar.barTintColor = [UIColor colorWithWhite:0.200 alpha:1.000];
        self.tabBar.tintColor = [UIColor whiteColor];
        
    }else{
        
        /**白天 */
        
        self.tabBar.barTintColor = [UIColor whiteColor];
        self.tabBar.tintColor = [UIColor grayColor];
    }
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nightAction:) name:@"night" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dayAction:) name:@"day" object:nil];
    
    
    
}
- (void)nightAction:(NSNotification *)notification {
    
    
    
    NSLog(@"夜间模式开始成功");
    self.tabBar.barTintColor = [UIColor colorWithWhite:0.200 alpha:1.000];
    self.tabBar.tintColor = [UIColor whiteColor];
    
    
    
}

- (void)dayAction:(NSNotification *)notification {
    
    NSLog(@"日间模式开启成功");
    
    self.tabBar.barTintColor = [UIColor whiteColor];
    self.tabBar.tintColor = [UIColor grayColor];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
